<!--移交案件弹窗-->

<template>
  <el-dialog append-to-body title="案件撤回" width="640px" :visible="visible" @close="handleClose">
    <el-form ref="form" :model="form" :rules="rules" label-suffix="：" class="white-card">
      <el-form-item label="案件撤回备注" prop="comment">
        <el-input v-model="form.comment" show-word-limit maxlength="300" placeholder="请输入详细描述" type="textarea" :autosize="{ minRows: 8 }"></el-input>
      </el-form-item>
    </el-form>
    <div class="split"></div>

    <div class="dialog-footer-btn">
      <el-button @click="handleClose" type="primary" plain>关闭</el-button>
      <el-button @click="handleSubmit" :loading="submitting" type="primary">确定</el-button>
    </div>
  </el-dialog>
</template>

<script>
import * as mixins from "@/utils/mixins";
import * as workOrderApi from "@/api/workOrder/index";
import * as templateApi from "@/api/template";

export default {
  name: "cancelAcceptDialog",
  mixins: [mixins.dialog, mixins.form],
  props: ["visible", "workOrderNo"],
  data() {
    return {
      form: {
        comment: "",
      },
      rules: {
        comment: [{ required: true, message: "请填写" }],
      },
      transferDepartmentTree: [],
      submitting: false,
    };
  },
  methods: {
    show() {
      // 撤回备注	1003
      templateApi.detailByCode(1003).then((res) => {
        this.form.comment = res.result.value;
      });
    },
    handleSubmit() {
      this.validateAndConfirm("form")
        .then((res) => {
          this.submitting = true;
          return workOrderApi.distribute.cancelDistribute({
            ...this.form,
            workOrderNo: this.workOrderNo,
          });
        })
        .then(() => {
          this.$emit("success");
          this.handleClose();
        })
        .finally(() => {
          this.submitting = false;
        });
    },
  },
};
</script>

<style scoped></style>
